#!/usr/bin/env pytho
# -*- coding: utf-8 -*-
# import collections
#
# a = [1,2,3,1,2,3,4,1,2,5,4,6,7,7,8,9,6,2,23,4,2,1,5,6,7,8,2]
# b = collections.Counter(a)
# for c in b:
#     print(c,b[c])


import re
from collections import Counter
lines=[]
ips=[]
with open('E:/find_IP.txt','r') as f:
    for line in f:
        ip=re.search('\d{3}\.\d{3}\.\d{3}\.\d{3}',line

        if ip is not None:
            ips.append(ip.group())

ip_counter=Counter(ips)
ip_c=ip_counter.most_common()

for item in ip_c:
    print("IP 地址:%s,访问次数:%d"%(item[0],item[1]))

print("访问总次数:%d"%len(ips))

